package org.light.generator;

import java.util.ArrayList;
import java.util.List;

import org.light.core.Writeable;
import org.light.domain.Statement;
import org.light.domain.StatementList;
import org.light.exception.ValidateException;
import org.light.utils.WriteableUtil;

public class JumpHomepageGenerator extends Generator{	
	private static final long serialVersionUID = -4790994605747142428L;
	protected boolean containsAuth = false;

	public boolean isContainsAuth() {
		return containsAuth;
	}

	public void setContainsAuth(boolean containsAuth) {
		this.containsAuth = containsAuth;
	}

	public JumpHomepageGenerator(){
		super();		
		this.standardName = "JumpHomepageGenerator";
		this.fileName = "index.html";
	}	
	
	@Override
	public StatementList generateStatementList() throws ValidateException {
    	List<Writeable> sList = new ArrayList<Writeable>();
        sList.add(new Statement(1000L,0,"<html>"));
        sList.add(new Statement(2000L,0,"<head>"));
		if (containsAuth){
        	sList.add(new Statement(3000L,0,"<meta http-equiv=\"refresh\"  content=\"0;url=login/index.html\"/>"));
		} else {
			sList.add(new Statement(3000L,0,"<meta http-equiv=\"refresh\"  content=\"0;url=pages/index.html\"/>"));
		}
        sList.add(new Statement(4000L,0,"</head>"));
        sList.add(new Statement(5000L,0,"<body>"));
        sList.add(new Statement(6000L,0,"</body>"));
    	return WriteableUtil.merge(sList);
	}
}
